﻿package view.expball
{
    import com.greensock.*;
    import com.greensock.easing.*;
    import flash.display.*;
    import morn.core.components.*;

    public class NumItem extends View
    {
        private var _preurl:String;
        private var _overNum:int = 0;
        private var _starNum:int = 0;
        private var _sigtime:int = 0;
        private var _overfun:Function;
        private var mark:Shape;
        private var imgBox:VBox;
        private var bob:int = 29;
        private var time:Number = 1;
        private var tweenmax:TweenMax;

        public function NumItem(param1:Function = null, param2:String = "png.common.pow2_")
        {
            this.mark = new Shape();
            this.mark.graphics.beginFill(0, 1);
            this.mark.graphics.drawRect(0, 0, 23, 29);
            this.addChild(this.mark);
            this.mask = this.mark;
            this.imgBox = new VBox();
            this.addChild(this.imgBox);
            this._preurl = param2;
            this._overfun = param1;
            return;
        }// end function

        public function setNum(param1:int) : void
        {
            var _loc_4:Image = null;
            this.imgBox.y = 0;
            while (this.imgBox.numChildren > 1)
            {
                
                this.imgBox.removeChildAt(0);
            }
            this._overNum = param1;
            if (this._overNum > 9)
            {
                throw Error("只支持一位数的数字");
            }
            var _loc_2:int = 0;
            while (_loc_2 < 5)
            {
                
                if (this._starNum < 9)
                {
                    var _loc_5:String = this;
                    var _loc_6:* = this._starNum + 1;
                    _loc_5._starNum = _loc_6;
                }
                else
                {
                    this._starNum = 0;
                }
                _loc_4 = new Image(this._preurl + this._starNum);
                this.imgBox.addChild(_loc_4);
                _loc_2++;
            }
            var _loc_3:* = new Image(this._preurl + this._overNum);
            this.imgBox.addChild(_loc_3);
            this.time = this.imgBox.numChildren * 0.02;
            this._starNum = this._overNum;
            this.tweenmax = TweenMax.to(this.imgBox, this.time, {y:-5 * this.bob, onComplete:this.Complete, ease:Circ.easeOut});
            return;
        }// end function

        private function Complete() : void
        {
            this.imgBox.y = 0;
            while (this.imgBox.numChildren > 1)
            {
                
                this.imgBox.removeChildAt(0);
            }
            if (this._overfun != null)
            {
                this._overfun();
            }
            return;
        }// end function

        public function destory() : void
        {
            return;
        }// end function

    }
}
